<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QDBusServiceWatcher Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QDBusServiceWatcher Class Reference<br /><sup><sup>[<a href="qtdbus.html">QtDBus</a> module]</sup></sup></h1><p>The QDBusServiceWatcher class allows the user to watch for a bus
service change. <a href="#details">More...</a></p>

<p>Inherits <a href="qobject.html">QObject</a>.</p><h3>Types</h3><ul><li><div class="fn" />class <b><a href="qdbusservicewatcher-watchmode.html">WatchMode</a></b></li><li><div class="fn" />enum <b><a href="qdbusservicewatcher.html#WatchModeFlag-enum">WatchModeFlag</a></b> { WatchForRegistration, WatchForUnregistration, WatchForOwnerChange }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qdbusservicewatcher.html#QDBusServiceWatcher">__init__</a></b> (<i>self</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qdbusservicewatcher.html#QDBusServiceWatcher-2">__init__</a></b> (<i>self</i>, QString&#160;<i>service</i>, QDBusConnection&#160;<i>connection</i>, WatchMode&#160;<i>watchMode</i>&#160;=&#160;QDBusServiceWatcher.WatchForOwnerChange, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qdbusservicewatcher.html#addWatchedService">addWatchedService</a></b> (<i>self</i>, QString&#160;<i>newService</i>)</li><li><div class="fn" />QDBusConnection <b><a href="qdbusservicewatcher.html#connection">connection</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qdbusservicewatcher.html#removeWatchedService">removeWatchedService</a></b> (<i>self</i>, QString&#160;<i>service</i>)</li><li><div class="fn" /><b><a href="qdbusservicewatcher.html#setConnection">setConnection</a></b> (<i>self</i>, QDBusConnection&#160;<i>connection</i>)</li><li><div class="fn" /><b><a href="qdbusservicewatcher.html#setWatchedServices">setWatchedServices</a></b> (<i>self</i>, QStringList&#160;<i>services</i>)</li><li><div class="fn" /><b><a href="qdbusservicewatcher.html#setWatchMode">setWatchMode</a></b> (<i>self</i>, WatchMode&#160;<i>mode</i>)</li><li><div class="fn" />QStringList <b><a href="qdbusservicewatcher.html#watchedServices">watchedServices</a></b> (<i>self</i>)</li><li><div class="fn" />WatchMode <b><a href="qdbusservicewatcher.html#watchMode">watchMode</a></b> (<i>self</i>)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qdbusservicewatcher.html#serviceOwnerChanged">serviceOwnerChanged</a></b> (const QString&amp;,const QString&amp;,const QString&amp;)</li><li><div class="fn" />void <b><a href="qdbusservicewatcher.html#serviceRegistered">serviceRegistered</a></b> (const QString&amp;)</li><li><div class="fn" />void <b><a href="qdbusservicewatcher.html#serviceUnregistered">serviceUnregistered</a></b> (const QString&amp;)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QDBusServiceWatcher class allows the user to watch for a bus
service change.</p>
<p>A QDBusServiceWatcher object can be used to notify the
application about an ownership change of a service name on the bus.
It has three watch modes:</p>
<ul>
<li>Watching for service registration only.</li>
<li>Watching for service unregistration only.</li>
<li>Watching for any kind of service ownership change (the default
mode).</li>
</ul>
<p>Besides being created or deleted, services may change owners
without a unregister/register operation happening. So the <a href="qdbusservicewatcher.html#serviceRegistered">serviceRegistered</a>()
and <a href="qdbusservicewatcher.html#serviceUnregistered">serviceUnregistered</a>()
signals may not be emitted if that happens.</p>
<p>This class is more efficient than using the <a href="qdbusconnectioninterface.html#serviceOwnerChanged">QDBusConnectionInterface.serviceOwnerChanged</a>()
signal because it allows one to receive only the signals for which
the class is interested in.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="WatchModeFlag-enum" />QDBusServiceWatcher.WatchModeFlag</h3><p><a href="qdbusservicewatcher.html">QDBusServiceWatcher</a>
supports three different watch modes, which are configured by this
flag:</p>
<table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign">
<tt>QDBusServiceWatcher.WatchForRegistration</tt></td>
<td class="topAlign"><tt>0x01</tt></td>
<td class="topAlign">watch for service registration only, ignoring
any signals related to other service ownership change.</td>
</tr>
<tr>
<td class="topAlign">
<tt>QDBusServiceWatcher.WatchForUnregistration</tt></td>
<td class="topAlign"><tt>0x02</tt></td>
<td class="topAlign">watch for service unregistration only,
ignoring any signals related to other service ownership
change.</td>
</tr>
<tr>
<td class="topAlign">
<tt>QDBusServiceWatcher.WatchForOwnerChange</tt></td>
<td class="topAlign"><tt>0x03</tt></td>
<td class="topAlign">watch for any kind of service ownership
change.</td>
</tr>
</table>
<p>The WatchMode type is a typedef for <a href="qflags.html">QFlags</a>&lt;WatchModeFlag&gt;. It stores an OR
combination of WatchModeFlag values.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QDBusServiceWatcher" />QDBusServiceWatcher.__init__ (<i>self</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Creates a <a href="qdbusservicewatcher.html">QDBusServiceWatcher</a> object. Note
that until you set a connection with <a href="qdbusservicewatcher.html#setConnection">setConnection</a>(), this
object will not emit any signals.</p>
<p>The <i>parent</i> parameter is passed to <a href="qobject.html">QObject</a> to set the parent of this object.</p>


<h3 class="fn"><a name="QDBusServiceWatcher-2" />QDBusServiceWatcher.__init__ (<i>self</i>, QString&#160;<i>service</i>, <a href="qdbusconnection.html">QDBusConnection</a>&#160;<i>connection</i>, <a href="qdbusservicewatcher-watchmode.html">WatchMode</a>&#160;<i>watchMode</i>&#160;=&#160;QDBusServiceWatcher.WatchForOwnerChange, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Creates a <a href="qdbusservicewatcher.html">QDBusServiceWatcher</a> object and
attaches it to the <i>connection</i> connection. Also, this
function immediately starts watching for <i>watchMode</i> changes
to service <i>service</i>.</p>
<p>The <i>parent</i> parameter is passed to <a href="qobject.html">QObject</a> to set the parent of this object.</p>


<h3 class="fn"><a name="addWatchedService" />QDBusServiceWatcher.addWatchedService (<i>self</i>, QString&#160;<i>newService</i>)</h3><p>Adds <i>newService</i> to the list of services to be watched by
this object. This function is more efficient than <a href="qdbusservicewatcher.html#watchedServices-prop">setWatchedServices</a>()
and should be used whenever possible to add services.</p>


<h3 class="fn"><a name="connection" /><a href="qdbusconnection.html">QDBusConnection</a> QDBusServiceWatcher.connection (<i>self</i>)</h3><p>Returns the <a href="qdbusconnection.html">QDBusConnection</a>
that this object is attached to.</p>
<p><b>See also</b> <a href="qdbusservicewatcher.html#setConnection">setConnection</a>().</p>


<h3 class="fn"><a name="removeWatchedService" />bool QDBusServiceWatcher.removeWatchedService (<i>self</i>, QString&#160;<i>service</i>)</h3><p>Removes the <i>service</i> from the list of services being
watched by this object. Note that D-Bus notifications are
asynchronous, so there may still be signals pending delivery about
<i>service</i>. Those signals will still be emitted whenever the
D-Bus messages are processed.</p>
<p>This function returns true if any services were removed.</p>


<h3 class="fn"><a name="setConnection" />QDBusServiceWatcher.setConnection (<i>self</i>, <a href="qdbusconnection.html">QDBusConnection</a>&#160;<i>connection</i>)</h3><p>Sets the D-Bus connection that this object is attached to be
<i>connection</i>. All services watched will be transferred to this
connection.</p>
<p>Note that <a href="qdbusconnection.html">QDBusConnection</a>
objects are reference counted: <a href="qdbusservicewatcher.html">QDBusServiceWatcher</a> will keep a
reference for this connection while it exists. The connection is
not closed until the reference count drops to zero, so this will
ensure that any notifications are received while this <a href="qdbusservicewatcher.html">QDBusServiceWatcher</a> object
exists.</p>
<p><b>See also</b> <a href="qdbusservicewatcher.html#connection">connection</a>().</p>
<h3 class="fn"><a name="setWatchedServices" />QDBusServiceWatcher.setWatchedServices (<i>self</i>, QStringList&#160;<i>services</i>)</h3><h3 class="fn"><a name="setWatchMode" />QDBusServiceWatcher.setWatchMode (<i>self</i>, <a href="qdbusservicewatcher-watchmode.html">WatchMode</a>&#160;<i>mode</i>)</h3><h3 class="fn"><a name="watchedServices" />QStringList QDBusServiceWatcher.watchedServices (<i>self</i>)</h3><h3 class="fn"><a name="watchMode" /><a href="qdbusservicewatcher-watchmode.html">WatchMode</a> QDBusServiceWatcher.watchMode (<i>self</i>)</h3><hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="serviceOwnerChanged" />void serviceOwnerChanged (const QString&amp;,const QString&amp;,const QString&amp;)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever this object detects that there
was a service ownership change relating to the <i>serviceName</i>
service. The <i>oldOwner</i> parameter contains the old owner name
and <i>newOwner</i> is the new owner. Both <i>oldOwner</i> and
<i>newOwner</i> are unique connection names.</p>
<p>Note that this signal is also emitted whenever the
<i>serviceName</i> service was registered or unregistered. If it
was registered, <i>oldOwner</i> will contain an empty string,
whereas if it was unregistered, <i>newOwner</i> will contain an
empty string.</p>
<p>If you need only to find out if the service is registered or
unregistered only, without being notified that the ownership
changed, consider using the specific modes for those operations.
This class is more efficient if you use the more specific
modes.</p>
<p><b>See also</b> <a href="qdbusservicewatcher.html#serviceRegistered">serviceRegistered</a>()
and <a href="qdbusservicewatcher.html#serviceUnregistered">serviceUnregistered</a>().</p>


<h3 class="fn"><a name="serviceRegistered" />void serviceRegistered (const QString&amp;)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever this object detects that the
service <i>serviceName</i> became available on the bus.</p>
<p><b>See also</b> <a href="qdbusservicewatcher.html#serviceUnregistered">serviceUnregistered</a>()
and <a href="qdbusservicewatcher.html#serviceOwnerChanged">serviceOwnerChanged</a>().</p>


<h3 class="fn"><a name="serviceUnregistered" />void serviceUnregistered (const QString&amp;)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever this object detects that the
service <i>serviceName</i> was unregistered from the bus and is no
longer available.</p>
<p><b>See also</b> <a href="qdbusservicewatcher.html#serviceRegistered">serviceRegistered</a>()
and <a href="qdbusservicewatcher.html#serviceOwnerChanged">serviceOwnerChanged</a>().</p>


<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;snapshot-4.9.5-9eb6aac99275 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.3</td></tr></table></div></address></body></html>